package com.qk.management.scheduled;

import com.qk.management.service.ReportOverviewService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Redis数据预热任务类
 * 实现在项目启动时预热门户数据
 */
@Slf4j
@Component
public class RedisDataPreloadTask{

    @Autowired
    private ReportOverviewService reportOverviewService;

    @Scheduled(cron = "0 0 2 * * ?  ")
    public void scheduleRefreshPortalData() {
        log.info("开始执行数据定时刷新任务");
        try {
            reportOverviewService.refreshPortalData();
        } catch (Exception e) {
            log.error("门户数据定时刷新任务执行失败", e);
        }
    }

}